package alidns

import (
	"net/http"

	"gitee.com/bitwormhole/cloud-aliyun-api/aliyun/openapi"
)

// AddDomainRecord 获取域名信息
type AddDomainRecord struct {
	Endpoint string

	DomainName string // (required)
	RR         string // (required)
	Type       string //  [A|NS|MX|TXT|CNAME|SRV|AAAA|CAA]  (required)
	Value      string // (required)

	Lang         string // (optional)
	UserClientIP string // (optional)
	Line         string // (optional)
	TTL          int64  // (optional)
	Priority     int64  // (optional)
}

// PrepareRequest ...
func (inst *AddDomainRecord) PrepareRequest() *openapi.Request {

	req := &openapi.Request{
		Task: inst,
	}

	action := "AddDomainRecord"
	version := "2015-01-09"

	req.Endpoint = inst.Endpoint
	req.HTTPMethod = http.MethodPost
	req.PathParameters = nil
	req.QueryParameters = nil
	req.Style = openapi.StyleRPC
	req.Action = action
	req.APIVersion = version

	setter := &paramSetter{request: req}

	setter.setParamString("Action", action)
	setter.setParamString("DomainName", inst.DomainName)
	setter.setParamString("RR", inst.RR)
	setter.setParamString("Type", inst.Type)
	setter.setParamString("Value", inst.Value)

	setter.setParamString("Lang", inst.Lang)
	setter.setParamString("UserClientIp", inst.UserClientIP)
	setter.setParamString("Line", inst.Line)
	setter.setParamInt64("TTL", inst.TTL)
	setter.setParamInt64("Priority", inst.Priority)

	return req
}

// HandleResponse ...
func (inst *AddDomainRecord) HandleResponse(req *openapi.Request) error {

	return nil
}
